local mou__duanliang = fk.CreateSkill {

  name = "joy_mou__duanliang",

  tags = {  },

}



mou__duanliang:addEffect("active", {
  name = "joy_mou__duanliang",
  anim_type = "control",
  mute = true,
  can_use = function(self, player)
    return player:usedSkillTimes(mou__duanliang.name, Player.HistoryPhase) < 2
  end,
  card_num = 0,
  card_filter = function() return false end,
  target_num = 1,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select ~= player.id
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local to = effect.tos[1]
    local id1
    if not player.dead then
     id1 = player:drawCards(1,mou__duanliang.name)
    end
    room:notifySkillInvoked(player, mou__duanliang.name)
    player:broadcastSkillInvoke(mou__duanliang.name, 1)
    local choices = U.doStrategy(room, player, to, {"mou__duanliang-weicheng","mou__duanliang-jinjun"}, {"mou__duanliang-tuji","mou__duanliang-shoucheng"}, mou__duanliang.name, 1)
    if choices[1] == "mou__duanliang-weicheng" and choices[2] ~= "mou__duanliang-tuji" then
      player:broadcastSkillInvoke(mou__duanliang.name, 2)
      local use
      if #id1 > 0 and table.every(id1, function(id) return table.contains(player:getCardIds("h"), id) end) then
        local card = Fk:cloneCard("supply_shortage")
        card.skillName = mou__duanliang.name
        card:addSubcard(id1[1])
        if U.canUseCardTo(room, player, to, card, false) then
          room:useVirtualCard("supply_shortage", {id1[1]}, player, to, mou__duanliang.name, true)
          use = true
        end
      end
      if not use and not to:isNude() then
        local id = room:askForCardChosen(player, to, "he", mou__duanliang.name)
        room:obtainCard(player, id, false, fk.ReasonPrey)
      end
    elseif choices[1] == "mou__duanliang-jinjun" and choices[2] ~= "mou__duanliang-shoucheng" then
      player:broadcastSkillInvoke(mou__duanliang.name, 3)
      room:useVirtualCard("duel", nil, player, to, mou__duanliang.name)
    else
      player:broadcastSkillInvoke(mou__duanliang.name, 4)
    end
  end,
})

return mou__duanliang